using System;
using System.Data;
using System.Collections;

namespace RMAS.DAL
{
    /// <summary>
    /// Summary description for DM_METERIAL.
    /// </summary>
    public class DM_METERIALList : CollectionBase
    {
		private string _ErrMsg;
        public string ErrMsg { get { return _ErrMsg; } }
    	public DM_METERIALList()
    	{
	    }

		public void Add(DM_METERIAL entity)
		{
            this.List.Add(entity);
		}

		public void Add(DM_METERIALList list)
		{	
			foreach(DM_METERIAL entity in list)
			{
				this.Add(entity);
			}
		}
	
		public new virtual Enumerator GetEnumerator()
		{
		    return new Enumerator(this);
		}
		public virtual DM_METERIAL this[int index]
		{
		    get
			{
				return (DM_METERIAL)this.List[index];
			}
			set
			{
				this.List[index] = value;
			}
		}

		#region Find Object And List Object
		//---PrimaryKey
	public virtual DM_METERIAL Find(string ID)
	{
	    foreach (DM_METERIAL obj in this.List)
	    {
		if(obj.ID.ToString().ToUpper().Trim() == ID.ToString().ToUpper().Trim())
		{
		    obj.IsExisting = true;
		    return obj;
		}
	    }
	    return null;
	}

public virtual DM_METERIALList FindListByID(string ID)
{
	try
	{
		DM_METERIALList List = new DM_METERIALList();
		foreach (DM_METERIAL obj in this.List)
		{
		    if(obj.ID.ToString().ToUpper().Trim() == ID.ToString().ToUpper().Trim())
		    {
				List.Add(obj);
		    }
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
    	{
		_ErrMsg = ex.Message;
        		return null;
    	}
}
		//---NonPrimaryKey
        public virtual DM_METERIAL FindByName(string Name)
        {
	        foreach (DM_METERIAL obj in this.List)
	        {
		        if(obj.Name.ToString().ToUpper().Trim() == Name.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_METERIAL FindByPrice(double Price)
        {
	        foreach (DM_METERIAL obj in this.List)
	        {
		        if(obj.Price.ToString().ToUpper().Trim() == Price.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_METERIAL FindByMinNumStore(double MinNumStore)
        {
	        foreach (DM_METERIAL obj in this.List)
	        {
		        if(obj.MinNumStore.ToString().ToUpper().Trim() == MinNumStore.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_METERIAL FindByMaxNumStore(double MaxNumStore)
        {
	        foreach (DM_METERIAL obj in this.List)
	        {
		        if(obj.MaxNumStore.ToString().ToUpper().Trim() == MaxNumStore.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_METERIAL FindByUnitID(string UnitID)
        {
	        foreach (DM_METERIAL obj in this.List)
	        {
		        if(obj.UnitID.ToString().ToUpper().Trim() == UnitID.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_METERIAL FindByGroupID(string GroupID)
        {
	        foreach (DM_METERIAL obj in this.List)
	        {
		        if(obj.GroupID.ToString().ToUpper().Trim() == GroupID.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_METERIAL FindByIsUsed(string IsUsed)
        {
	        foreach (DM_METERIAL obj in this.List)
	        {
		        if(obj.IsUsed.ToString().ToUpper().Trim() == IsUsed.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_METERIAL FindByFirstBalancer(double FirstBalancer)
        {
	        foreach (DM_METERIAL obj in this.List)
	        {
		        if(obj.FirstBalancer.ToString().ToUpper().Trim() == FirstBalancer.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual DM_METERIAL FindByIDPOS(string IDPOS)
        {
	        foreach (DM_METERIAL obj in this.List)
	        {
		        if(obj.IDPOS.ToString().ToUpper().Trim() == IDPOS.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

public virtual DM_METERIALList FindListByName(string Name)
{
	try
	{
		DM_METERIALList List = new DM_METERIALList();
		foreach (DM_METERIAL obj in this.List)
		{
			if(obj.Name.ToString().ToUpper().Trim() == Name.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_METERIALList FindListByPrice(double Price)
{
	try
	{
		DM_METERIALList List = new DM_METERIALList();
		foreach (DM_METERIAL obj in this.List)
		{
			if(obj.Price.ToString().ToUpper().Trim() == Price.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_METERIALList FindListByMinNumStore(double MinNumStore)
{
	try
	{
		DM_METERIALList List = new DM_METERIALList();
		foreach (DM_METERIAL obj in this.List)
		{
			if(obj.MinNumStore.ToString().ToUpper().Trim() == MinNumStore.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_METERIALList FindListByMaxNumStore(double MaxNumStore)
{
	try
	{
		DM_METERIALList List = new DM_METERIALList();
		foreach (DM_METERIAL obj in this.List)
		{
			if(obj.MaxNumStore.ToString().ToUpper().Trim() == MaxNumStore.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_METERIALList FindListByUnitID(string UnitID)
{
	try
	{
		DM_METERIALList List = new DM_METERIALList();
		foreach (DM_METERIAL obj in this.List)
		{
			if(obj.UnitID.ToString().ToUpper().Trim() == UnitID.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_METERIALList FindListByGroupID(string GroupID)
{
	try
	{
		DM_METERIALList List = new DM_METERIALList();
		foreach (DM_METERIAL obj in this.List)
		{
			if(obj.GroupID.ToString().ToUpper().Trim() == GroupID.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_METERIALList FindListByIsUsed(string IsUsed)
{
	try
	{
		DM_METERIALList List = new DM_METERIALList();
		foreach (DM_METERIAL obj in this.List)
		{
			if(obj.IsUsed.ToString().ToUpper().Trim() == IsUsed.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_METERIALList FindListByFirstBalancer(double FirstBalancer)
{
	try
	{
		DM_METERIALList List = new DM_METERIALList();
		foreach (DM_METERIAL obj in this.List)
		{
			if(obj.FirstBalancer.ToString().ToUpper().Trim() == FirstBalancer.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual DM_METERIALList FindListByIDPOS(string IDPOS)
{
	try
	{
		DM_METERIALList List = new DM_METERIALList();
		foreach (DM_METERIAL obj in this.List)
		{
			if(obj.IDPOS.ToString().ToUpper().Trim() == IDPOS.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}
		#endregion
     
		#region Inner Classes
		/// <summary>
		/// Type-specific enumeration class, used by LogCollection.GetEnumerator.
		/// </summary>
		public class Enumerator : IEnumerator
		{
			private IEnumerator wrapped;

			public Enumerator(DM_METERIALList collection)
			{
				this.wrapped = ((CollectionBase)collection).GetEnumerator();
			}

			public DM_METERIAL Current
			{
				get
				{
					return (DM_METERIAL)(this.wrapped.Current);
				}
			}

			object IEnumerator.Current
			{
				get
				{
					return (DM_METERIAL)(this.wrapped.Current);
				}
			}

			public bool MoveNext()
			{
				return this.wrapped.MoveNext();
			}

			public void Reset()
			{
				this.wrapped.Reset();
			}
      }
      #endregion  
   }
}